//文件管理维护
OB.Emes_ActionButton = OB.Emes_ActionButton || {};
//上传文件
OB.Emes_ActionButton.FmFileUpload = function(params, view){
	var viewGrid = view.activeView.viewGrid;
	var record = viewGrid.getSelectedRecord();
	var row = viewGrid.getRecordIndex(record);
	if (record) {
		OB.Layout.ClassicOBCompatibility.Popup.open('fileManagerUpload', 500, 420,OB.Application.contextUrl + 'web/com.mes/html/fileManagerUpload.html?fileTypeId='+record.id,    
				'文件上传', window, false, false, null, true, true);
		OB.Emes_ActionButton.FmFileRefresh=function(){
			viewGrid.refreshGrid();
		};
	} else {
		isc.showMessage("请选择记录！");
	}
};
//编辑修改
OB.Emes_ActionButton.FmFileEdit = function(params, view){
	var viewGrid = view.activeView.viewGrid;
	var record = viewGrid.getSelectedRecord();
	var row = viewGrid.getRecordIndex(record);
	if (record) {
		OB.Layout.ClassicOBCompatibility.Popup.open('fileManagerUpload', 500, 420,OB.Application.contextUrl + 'web/com.mes/html/fileManagerUpload.html?recordId='+record.id+'&fileTypeId='+record.id,    
				'文件上传', window, false, false, null, true, true);
		OB.Emes_ActionButton.FmFileRefresh=function(){
			viewGrid.refreshGrid();
		};
	} else {
		isc.showMessage("请选择记录！");
	}
};
//查看文件
OB.Emes_ActionButton.FmFileView = function(params, view){
	var viewGrid = view.activeView.viewGrid;
	var record = viewGrid.getSelectedRecord();
	var row = viewGrid.getRecordIndex(record);
	if (record) {
		//isc.showMessage("查看文件！"+record.fileurl);
		window.open("DownFileServlet.html?path=" + encodeURIComponent(record.filepath) + "&online=false&fileName="+record.filefullname,"_blank");
		//isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(record.filepath) + "&online=false&fileName="+record.filefullname}).show();
	} else {
		isc.showMessage("请选择记录！");
	}
};
//删除文件
OB.Emes_ActionButton.FmFileDel = function(params, view){
	var viewGrid = view.activeView.viewGrid;
	var record = viewGrid.getSelectedRecord();
	var row = viewGrid.getRecordIndex(record);
	if (record) {
		isc.confirm("确定删除文件？", function(bool){
			if (bool) {
				var data = {
					recordId: record.id
				};
				var callback = function(response, data, request){
					isc.showMessage(data.msg);
					if(data.result){
						view.refresh();
					}
				};
				OB.RemoteCallManager.call("com.mes.handler.FileManagerDelHandler", data, {}, callback);
			}
		});
	} else {
		isc.showMessage("请选择记录！");
	}
};